/*
 * test_curl.cpp
 *
 *  Created on: Feb 13, 2014
 *      Author: killerg
 */




#include <stdio.h>
#include <curl/curl.h>

#define SKIP_PEER_VERIFICATION 1
#define SKIP_HOSTNAME_VERIFICATION 1

bool test_curl()
{
  CURL *curl;
  CURLcode res;

  res = curl_global_init(CURL_GLOBAL_SSL);
  curl_version_info_data *vinfo = curl_version_info( CURLVERSION_NOW );
  if( vinfo->features & CURL_VERSION_SSL )
  {
	  printf("ssl supported\n");
  }

  printf("%s\n", curl_version());
  curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "https://openapi.360.cn/user/me.json");

    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);

    /* Perform the request, res will get the return code */
    res = curl_easy_perform(curl);
    /* Check for errors */
    if(res != CURLE_OK)
      fprintf(stderr, "curl_easy_perform() failed: %s\n",
              curl_easy_strerror(res));

    /* always cleanup */
    curl_easy_cleanup(curl);
  }

  curl_global_cleanup();

  return 0;
}
